<template>
  <div class="main">
    <div class="page__header">
      <div class="page__header">
        <div  class="page__header__box activeBox" style="margin-top: 0px">
          <div  class="page__header__nav">
            <div class="nav__sign">
              <a  href="/" class="logo"
                ><img  src="./images/juejin-logo.png" alt="" class="logo__img"
              /></a>
            </div>
            <div class="nav__main">
              <ul class="nav__main-list">
                <li  class="list-left" style="width: 100%">
                  <div  class="list-left-list">
                    <ul class="list__contents" style="display: flex">
                      <li >
                        <a href="#" style="color: rgb(30, 128, 255)">首页</a>
                      </li>
                      <li >
                        <a href="#">沸点</a>
                      </li>
                      <li >
                        <a href="#">课程</a>
                      </li>
                      <li >
                        <a  href="#">直播</a>
                      </li>
                      <li >
                        <a  href="#">资讯</a>
                      </li>
                      <li >
                        <a href="#">活动</a>
                      </li>
                      <li  class="com">
                        <a  href="#" class="community">开放社区</a>
                        <ul  class="community__list">
                          <li  class="item">
                            <span >青训营社区</span>
                          </li>
                        </ul>
                      </li>
                      <li >
                        <a  href="#">商城</a>
                      </li>
                      <li >
                        <a  href="#">APP</a>
                      </li>
                      <li >
                        <a  href="#">插件</a>
                      </li>
                    </ul>
                  </div>
                </li>
                <li  class="list-right">
                  <div  class="list-right-list">
                    <ul  class="list__contents">
                      <li >
                        <div  tabindex="0" class="input__frame">
                          <input
                            type="text"
                            placeholder="搜索稀土掘金"
                            class="input"
                          />
                          <div class="input__sign">
                            <div class="input__img"></div>
                          </div>
                          <div class="input__typehead">
                            <div class="title">
                              <span>搜索历史</span
                              ><span
                                class="clear"
                                style="color: rgb(30, 128, 255)"
                                >清空</span
                              >
                            </div>
                            <div class="list">
                              <ul>
                                <li class="list-item">HTML基础</li>
                                <li class="list-item">CSS样式</li>
                                <li class="list-item">JavaScript入门</li>
                                <li class="list-item">node</li>
                                <li class="list-item">vue 3</li>
                              </ul>
                            </div>
                          </div>
                        </div>
                      </li>
                      <li>
                        <div class="creator">
                          <button class="crea-btn">创作者中心</button
                          ><input type="checkbox" id="dianj" /><label
                            for="dianj"
                          >
                            <div class="more">
                              <div  class="more__tri"></div>
                            </div>
                          </label>
                          <!-- <ul  class="more__list">
                                  <li class="item">
                                    <span >写文章</span>
                                  </li>
                                  <li  class="item">
                                    <span >发沸点</span>
                                  </li>
                                </ul> -->
                        </div>
                      </li>
                      <li >
                        <div  class="vip__title">
                          <img
                            
                            src="https://lf3-cdn-tos.bytescm.com/obj/static/xitu_juejin_web/24127194d5b158d7eaf8f09a256c5d01.svg"
                            alt=""
                            class="vip__img"
                          />
                          <div  class="vip__words">会员</div>
                        </div>
                      </li>
                      <li >
                        <div class="inform">
                          <div class="inform__img"></div>
                        </div>
                      </li>
                      <li>
                        <div  class="user">
                          <img
                            src="https://p26-passport.byteacctimg.com/img/user-avatar/2328a5d0b4593d8b3af5a2ce154ced35~300x300.image"
                            alt=""
                            class="user__img"
                          />
                        </div>
                      </li>
                    </ul>
                  </div>
                </li>
              </ul>
            </div>
          </div>
          <!---->
        </div>
        <div lass="page__header__side" style="display: none">
          <a href="javascript:scroll(0,0)">
            <div class="backTop">
              <img
                src=""
                alt=""
              />
            </div>
          </a>
        </div>
      </div>
    </div>
    <div class="sidebar">
      <div  class="author-block">
        <div  class="user-item">
          <div class="userimg">
            <img
              alt="用户头像"
              src="https://p26-passport.byteacctimg.com/img/user-avatar/2328a5d0b4593d8b3af5a2ce154ced35~300x300.image"
            />
          </div>
          <div  class="info-box">
            <div  class="userName">
              <span>User-Agent</span
              ><img
                src="https://lf3-cdn-tos.bytescm.com/obj/static/xitu_juejin_web/img/lv-1.9d93e13.png"
                alt=""
              />
            </div>
            <div  class="position">学生</div>
          </div>
        </div>
        <div class="stat-item">
          <div >
            <img
              src=""
              alt=""
            />
          </div>
          <span >获得点赞 1</span>
        </div>
        <div class="stat-item">
          <div >
            <img
              src=""
              alt=""
            />
          </div>
          <span >文章被阅读 60</span>
        </div>
      </div>
      <div class="sticky-block-box activeBox" style="margin-top: 60px">
      </div>
    </div>
    <div class="right">
      <div class="data-celan">
        <div class="panel-btn">
          <img src="./images/zan.png" />
          <div class="btn-num">1</div>
        </div>
        <div class="panel-btn">
          <img src="./images/xinxi.png" />
        </div>
        <div class="panel-btn">
          <img src="./images/shoucang.png" />
        </div>
        <div class="panel-btn">
          <img src="./images/zhuanfa.png" />
        </div>
        <div class="panel-btn">
          <img src="./images/jubao.png" />
        </div>
        <div class="panel-btn">
          <img src="./images/saomiao.png" />
        </div>
      </div>
    </div>
    <div class="left"></div>
    <!-- 文章主体 -->
    <div class="markdown-body">
      <div>
        <h1 data-id="heading-0">这是我参与「第四届青训营」笔记创作活动的的第4天</h1>
        <h2 data-id="heading-1" class="section">关于前端开发</h2>
        <h3 data-id="heading-2" class="section">起源、架构、变迁</h3>
        <blockquote>
          <ul>
            <li>1989-2004：HTML、css、JavaScript</li>
            <li>2005-2010：ajax、web API、jquery</li>
            <li>2010-2021：fetch、node.js、webpack</li>
          </ul>
        </blockquote>
        <p>
          目前现代而言，界面美化越来越重要，前端工程师得到了认可和出现大量需求。
          <code>模块化、组件化、转译、打包、react.js、vue.js</code>是目前的重要学习方向
        </p>
        <h3 data-id="heading-3" class="section">前端应用的领域</h3>
        <ul>
          <li>
            <p>浏览器：<code>chrome</code>、edge、火狐</p>
          </li>
          <li>
            <p>服务器：<code>Node.js</code>、express.js</p>
          </li>
          <li>
            <p>终端和跨端：</p>
          </li>
        </ul>
        <ol>
          <li>命令行/终端：webpack/Babel/Vue/React + CLI</li>
          <li>桌面跨端：Electron、NW.js</li>
          <li>移动跨端：React、Native、Flutter</li>
        </ol>
        <h3 data-id="heading-4" class="section">语言、框架、工具</h3>
        <p>HTML、css、javascript+<code>WebAssembly</code></p>
        <p>其中<code>WebAssembly</code>：</p>
        <ul>
          <li>接近于<code>原生语言</code>，</li>
          <li>类似于<code>汇编语言</code>，</li>
          <li><code>响应速度快</code>，</li>
          <li>适合于需要精准、快速的应用工程，</li>
          <li>当前更多的是用<code>C++、c</code>、react来写</li>
          <li><code>任何</code>可以转译为WebAssembly的语言架构都将进行转译。</li>
        </ul>
        <!-- 添加侧边目录 -->
        <nav style="position: fixed; right: 0px; top: 190px" class="catalog">
          <el-card>
            <div style="margin-left: 26px; font-size: 16px">目录</div>
            <el-tabs
              @tab-click="handleClick"
              v-model="activeName"
              :tab-position="tabPosition"
              style="height: 400px !important"
            >
              <el-tab-pane
                :name="'tab' + index"
                :class="index == 0 ? 'current' : ''"
                v-for="(item, index) in list"
                :key="index"
                :label="item.name"
              ></el-tab-pane>
            </el-tabs>
          </el-card>
        </nav>
        <h3 data-id="heading-5" class="section">浏览器、网络、服务器：</h3>
        <ul>
          <li>
            理解浏览器：可阅览<code>《深入理解现代浏览器》</code>：理解具体一条指令浏览器哪个线程执行、怎么返回显示
          </li>
          <li>理解网络：<code>An overview of http</code>文档</li>
        </ul>
        <h3 data-id="heading-6" class="section">学习路线图：</h3>
        <p>
          可进入<a
            href="https://link.juejin.cn?target=https%3A%2F%2Froadmap.sh"
            target="_blank"
            rel="nofollow noopener noreferrer"
            title="https://roadmap.sh"
            ref="nofollow noopener noreferrer"
            >roadmap.sh</a
          >
          选择自己想要学习的语言或方向，根据具体标签选择性制定自己的学习路线
        </p>
        <h2 data-id="heading-7" class="section">关于Web标准</h2>
        <h3 data-id="heading-8">了解Web标准组织：</h3>
        <ul>
          <li>
            W3C（√基本认为都是这个）： 官网：<a
              href="https://link.juejin.cn?target=https%3A%2F%2Fwww.w3.org"
              target="_blank"
              rel="nofollow noopener noreferrer"
              title="https://www.w3.org"
              ref="nofollow noopener noreferrer"
              >www.w3.org</a
            >
            规范查询：<a
              href="https://link.juejin.cn?target=https%3A%2F%2Fwww.w3.org%2FTR"
              target="_blank"
              rel="nofollow noopener noreferrer"
              title="https://www.w3.org/TR"
              ref="nofollow noopener noreferrer"
              >www.w3.org/TR</a
            >
          </li>
          <li>
            Ecma： 官网：<a
              href="https://link.juejin.cn?target=https%3A%2F%2Fwww.ecma-international.org"
              target="_blank"
              rel="nofollow noopener noreferrer"
              title="https://www.ecma-international.org"
              ref="nofollow noopener noreferrer"
              >www.ecma-international.org</a
            >
          </li>
          <li>WHATWG</li>
          <li>IETF</li>
        </ul>
        <p>
          中国目前有Ecma的AM会员有6家，在西班牙的<code>igalia</code>公司是由谷歌原员工创建的，可多关注。
        </p>
        <p>如感兴趣可以去了解一下w3c会议和Ecma会议的流程，每个人都可以是参与者！</p>
        <h2 data-id="heading-9" class="section">关于大项目的进度</h2>
        <ul>
          <li>昨天组队表公示了，已经确认了组队</li>
          <li>
            今天的额外任务就是得了解仿掘金官网的<code>具体功能需求、实现技术、具体框架和规范</code>!
          </li>
          <li>just do it！坚持下去！</li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      activeName: 'tab0',
      tabPosition: 'right',
      scroll: '',
      list: [
        {
          name: '关于前端开发'
        },
        {
          name: '起源、架构、变迁'
        },
        {
          name: '前端应用的领域'
        },
        {
          name: '语言、框架、工具'
        },
        {
          name: '浏览器、网络、服务器'
        },
        {
          name: '学习路线图'
        },
        {
          name: '关于Web标准'
        },
        {
          name: '了解Web标准组织'
        },
        {
          name: '关于大项目的进度'
        }
      ],
      navList: [1, 2, 3, 4, 5, 6, 7, 8, 9]
    };
  },
  methods: {
    //这里传入的tab相当于item
    handleClick(tab) {
      console.log(tab.index);
      this.jump(tab.index);
    },
    dataScroll: function () {
      this.scroll = document.documentElement.scrollTop || document.body.scrollTop;
    },
    jump(index) {
      let jump = document.getElementsByClassName('section');
      // 获取需要滚动的距离
      let total = jump[index].offsetTop;
      // Chrome
      document.body.scrollTop = total;
      // Firefox
      document.documentElement.scrollTop = total;
      // Safari
      window.pageYOffset = total;
      // $('html, body').animate({
      // 'scrollTop': total
      // }, 400);
    },
    // 用循环的方式将每个标题离顶部的距离与滚动条当前位置对比来确定哪个标题需要变为高亮
    loadScroll: function () {
      var self = this;
      var sections = document.getElementsByClassName('section');
      for (var i = sections.length - 1; i >= 0; i--) {
        if (self.scroll >= sections[i].offsetTop - 100) {
          //我在上面规定了每个el-tab-pane标签的name属性值为tab+该标签的index值
          self.activeName = 'tab' + i;
          break;
        }
      }
    }
  },
  watch: {
    //监听scroll变量，只要滚动条位置变化就会执行方法loadScroll
    scroll: function () {
      this.loadScroll();
    }
  },
  mounted() {
    // scroll代表滚动条距离页面顶部距离
    window.addEventListener('scroll', this.dataScroll);
  }
};
</script>

<style>
ul,
li {
  margin: 0;
  padding: 0;
}

li {
  list-style: none;
}

h1,
h2 {
  margin: 0;
}

p {
  margin: 0;
  padding: 0;
}

.main {
  background: #f2f2f2;
}

.right {
  width: 48px;
  height: 300px;
  position: fixed;
  top: 140px;
  left: 100px;
}

.btn-num {
  position: absolute;
  top: 0;
  left: 75%;
  height: 17px;
  line-height: 17px;
  padding: 0 5px;
  border-radius: 9px;
  font-size: 11px;
  text-align: center;
  white-space: nowrap;
  background-color: #c2c8d1;
  color: #fff;
}

.page__header {
  width: 100%;
  height: 60px;
}

.activeBox {
  transition: all 0.3s linear;
}

.page__header__nav {
  width: 100%;
  height: 60px;
  display: flex;
  justify-content: center;
  position: relative;
  top: 0;
  background: #fff;
}

.nav__sign {
  display: flex;
}

a {
  text-decoration: none;
  color: #515767;
}

.logo__img {
  width: 107px;
  height: 22px;
  margin-left: 24px;
  margin-top: 20px;
}

div {
  display: block;
}

.nav__main-list {
  height: 100%;
  display: flex;
}

.list-left,
.list-right {
  display: flex;
}

.list__contents {
  height: 100%;
  display: flex;
  margin-left: 10px;
}

.list__contents > li {
  display: flex;
  font-size: 0.9rem;
  align-items: center;
  margin: 0 0.65rem;
}

.list-left,
.list-right {
  display: flex;
}

.list__contents {
  height: 100%;
  display: flex;
  margin-left: 10px;
}

.list__contents > li {
  display: flex;
  font-size: 0.9rem;
  align-items: center;
  margin: 0 0.65rem;
}

.input__frame {
  height: 36px;
  border: 1px solid #86909ccf;
  border-radius: 3px;
  display: flex;
  align-items: center;
}

.input__frame .input {
  flex: 1;
  width: 316px;
  height: 12px;
  border: none;
  padding: 12px 7px;
  -webkit-text-fill-color: var(--juejin-font-3);
}

.input__frame .input__sign {
  width: 44px;
  height: 30px;
  background: #86909c23;
  border-radius: 3px;
  margin-right: 3px;
}

.input__sign .input__img {
  width: 16px;
  height: 16px;
  background-size: 16px 16px;
  margin: 7px 15px;
}

.input__frame .input__typehead {
  display: none;
  position: absolute;
  top: 52px;
  width: auto;
  background: #fff;
  border: 1px solid #5157613d;
  border-radius: 2px;
  z-index: 10;
  font-size: 0.8rem;
  color: var(--juejin-font-3);
}

.input__typehead .title {
  width: 100%;
  display: flex;
  justify-content: space-between;
  position: relative;
}

.creator {
  height: 36px;
  display: flex;
}

.creator .crea-btn {
  width: 80px;
  height: 100%;
  font-size: 0.8rem;
  color: #fff;
  background-color: var(--juejin-brand-1-normal);
  border: none;
  border-radius: 3px 0 0 3px;
  position: relative;
}

.crea-btn:after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 1px;
  height: 36px;
  background-color: var(--juejin-brand-4-disable);
  transform: scaleX(0.3);
}

#dianj {
  display: none;
}

label {
  cursor: default;
}

.creator .more {
  width: 20px;
  height: 100%;
  background-color: var(--juejin-brand-1-normal);
  border-radius: 0 3px 3px 0;
}

.more__tri {
  width: 0;
  height: 0;
  border: 4px solid #fff;
  border-left-color: transparent;
  border-top-color: transparent;
  transform: rotate(45deg);
  position: relative;
  top: 12px;
  left: 6px;
}

.title {
  font-size: 18px;
  line-height: 30px;
  font-weight: 600;
  color: #252933;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
}

.title > span {
  display: inline-block;
  margin: 10px;
}

.input__typehead .list .list-item {
  width: 342px;
  display: flex;
  padding: 10px;
}

.vip__title {
  height: 100%;
  display: flex;
  align-items: center;
  color: var(--juejin-font-3);
}

.inform {
  height: 100%;
  display: flex;
  align-items: center;
}

.inform__img {
  width: 24px;
  height: 24px;
  background-image: url();
  background-size: 24px 24px;
}

.user {
  height: 100%;
  display: flex;
  align-items: center;
}

.user__img {
  width: 36px;
  height: 36px;
  -o-object-fit: cover;
  object-fit: cover;
  border-radius: 50%;
}

.page__header__nav:after {
  content: '';
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 1px;
  background-color: var(--juejin-font-4);
  transform: scaleY(0.5);
}

.panel-btn {
  width: 100%;
  height: 48px;
  border-radius: 50%;
  background: #fff;
  margin-bottom: 20px;
  box-shadow: 1px 1px 20px #dadddd;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

.panel-btn > img {
  width: 17px;
  height: 17px;
}

.panel-btn:nth-child(4) {
  margin-bottom: 40px;
  position: relative;
}

.panel-btn:nth-child(4):after {
  content: '';
  position: absolute;
  bottom: -20px;
  width: 30px;
  height: 1px;
  background: rgba(0, 0, 0, 0.157);
  transform: scaleY(0.5);
}

.sidebar {
  position: absolute;
  top: 30px;
  right: 0;
  width: 200px;
  height: 150px;
  padding: 20px;
  flex: 1;
  background: #fff;
  margin-top: 60px;
  margin-right: 30px;
}

.sidebar > div {
  margin-bottom: 20px;
  box-sizing: border-box;
  border-radius: 4px;
  background: #fff;
}

.user-item {
  display: flex;
  padding-bottom: 17px;
  position: relative;
}

.userimg,
.userimg > img {
  height: 48px;
}

.userimg {
  width: 48px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

.info-box {
  margin-left: 16px;
}

.info-box .userName {
  color: #252933;
  display: flex;
  align-items: center;
}

.info-box > div {
  max-width: 196px;
  height: 24px;
  font-size: 16px;
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.userName > span {
  max-width: 155px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.userName > img {
  width: 35px;
  height: 16px;
}

.user-item:after {
  content: '';
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 1px;
  background: rgba(0, 0, 0, 0.178);
  transform: scaleY(0.5);
}

.stat-item {
  margin-top: 17px;
  display: flex;
  font-size: 15px;
  line-height: 25px;
  color: #252933;
}

.stat-item > div {
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background: #e1efff;
  margin-right: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.stat-item img {
  width: 16px;
  height: 16px;
}

.sidebar > div {
  margin-bottom: 20px;
  box-sizing: border-box;
  border-radius: 4px;
  background: #fff;
}

:root {
  --juejin-brand-1-normal: #1e80ff;
  --juejin-brand-2-hover: #1171ee;
  --juejin-brand-3-click: #0060dd;
  --juejin-brand-4-disable: #abcdff;
  --juejin-brand-5-light: #eaf2ff;
  --juejin-font-1: #252933;
  --juejin-font-2: #515767;
  --juejin-font-3: #8a919f;
  --juejin-font-4: #c2c8d1;
}

/* 文章主体 */
.markdown-body {
  width: 55%;
  padding: 40px;
  text-align: left;
  position: relative;
  left: 160px;
  top: 30px;
}

/* 侧边目录 */
.catalog {
  margin-right: 30px;
  width: 248px;
}

#tab-tab1,
#tab-tab2,
#tab-tab3,
#tab-tab4,
#tab-tab5,
#tab-tab7 {
  margin-left: 16px;
}
</style>
